package c.b.a.c.a.d;

import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import c.b.a.c.a.c.a;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public abstract class c<StateT> {

    /* renamed from: a  reason: collision with root package name */
    protected final a f1985a;

    /* renamed from: b  reason: collision with root package name */
    private final IntentFilter f1986b;

    /* renamed from: c  reason: collision with root package name */
    private final Context f1987c;

    /* renamed from: d  reason: collision with root package name */
    protected final Set<a<StateT>> f1988d = new HashSet();
    private b e = null;
    private volatile boolean f = false;

    protected c(a aVar, IntentFilter intentFilter, Context context) {
        this.f1985a = aVar;
        this.f1986b = intentFilter;
        this.f1987c = c.b.a.c.a.f.a.a(context);
    }

    private final void e() {
        b bVar;
        if ((this.f || !this.f1988d.isEmpty()) && this.e == null) {
            b bVar2 = new b(this);
            this.e = bVar2;
            this.f1987c.registerReceiver(bVar2, this.f1986b);
        }
        if (!this.f && this.f1988d.isEmpty() && (bVar = this.e) != null) {
            this.f1987c.unregisterReceiver(bVar);
            this.e = null;
        }
    }

    /* access modifiers changed from: protected */
    public abstract void a(Context context, Intent intent);

    public final synchronized void b(StateT statet) {
        Iterator it = new HashSet(this.f1988d).iterator();
        while (it.hasNext()) {
            ((a) it.next()).a(statet);
        }
    }

    public final synchronized void c(boolean z) {
        this.f = z;
        e();
    }

    public final synchronized boolean d() {
        return this.e != null;
    }
}
